﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;
using Simple.Services.System.QHSEDanger.Models.AnalysisInput;
using Simple.Services.System.QHSEViolationCategory.Models;

namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 隐患级别分析
/// </summary>
[Route("QHSEDangerTypeAnalysis/[action]")]
[ApiController]
public class QHSEDangerTypeAnalysisController : ControllerBase
{
    private readonly DangerTypeAnalysisService _dangerTypeAnalysisService;

    public QHSEDangerTypeAnalysisController(DangerTypeAnalysisService dangerTypeAnalysisService)
    {
        _dangerTypeAnalysisService = dangerTypeAnalysisService;
    }
    /// <summary>
    /// 隐患级别分析--隐患级别
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_jb_analysis")]
    public async Task<AppResult> DangerTypeAnalysis([FromBody] DangerAnalysisInput  input)
    {
        var res = await _dangerTypeAnalysisService.DangerTypeAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 隐患级别分析--通用/专业
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_jb_analysis")]
    public async Task<AppResult> ViolationTypeCategoryAnalysis([FromBody] DangerAnalysisInput input)
    {
        var res = await _dangerTypeAnalysisService.DangerTypeCategoryAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 隐患级别分析--各专业隐患性质
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_jb_analysis")]
    public async Task<AppResult> WorkSpecialityAnalysis([FromBody] DangerAnalysisInput input)
    {
        var res = await _dangerTypeAnalysisService.WorkSpecialityAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 隐患级别分析--整改情况
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_jb_analysis")]
    public async Task<AppResult> DangerStatusAnalysis([FromBody] DangerAnalysisInput input)
    {
        var res = await _dangerTypeAnalysisService.DangerStatusAnalysisAsync(input);
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 隐患级别分析--物的不安全状态/环境不良
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_jb_analysis")]
    public async Task<AppResult> UnsafeFactorsAnalysis([FromBody] DangerAnalysisInput input)
    {
        var res = await _dangerTypeAnalysisService.DangerCategoryAnalysisAsync(input,"不安全因素");
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 隐患级别分析--物的不安全状态
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_jb_analysis")]
    public async Task<AppResult> UnsafeBehaviorAnalysis([FromBody] DangerAnalysisInput input)
    {
        var res = await _dangerTypeAnalysisService.DangerCategoryAnalysisAsync(input, "物的不安全状态");
        return AppResult.Status200OK(data: res);
    }
    /// <summary>
    /// 隐患级别分析--环境不良
    /// </summary>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_d_jb_analysis")]
    public async Task<AppResult> ManagementDeficienciesAnalysis([FromBody] DangerAnalysisInput input)
    {
        var res = await _dangerTypeAnalysisService.DangerCategoryAnalysisAsync(input, "环境不良");
        return AppResult.Status200OK(data: res);
    }
}
